package bairui.international.console.web.controller.index.module;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.model.common.annotation.Comment;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_IndexModuleProduct;
import bairui.international.model.domain.jpa.id.ID_IndexModuleProduct;
import bairui.international.service.Service_IndexModuleProduct;
import lombok.Getter;
import lombok.Setter;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_Index_Module_Detail_ProductEdit 测试
 *
 */
@Controller
public class C_Index_Module_Detail_ProductEdit
 extends SC_Index_Module_Detail_ProductEdit 
{
	
	@Autowired private Service_IndexModuleProduct service_IndexModuleProduct;
	
	/**
	 * 编辑产品模块
	 */
	@Action(ProductEdit.class)
	@PutMapping(ProductEdit.RequestMappingValue)
	public @FomatOutput @ResponseBody Object productEdit(
		@PathVariable(name=ProductEdit.PathVariableName.Id) long id, // 解决数据绑定时的配置错误
//		@Valid ProductEdit.InputModel input, 
		@Valid InputModel input, 
		@PathVariable(name=ProductEdit.PathVariableName.ProductModuleId) ID_IndexModuleProduct productModuleId
	) throws Exception {
		SaveModel bean = new SaveModel(productModuleId);
			bean.setOrderValue(input.getOrderValue());
			bean.setComment(input.getComment());
		service_IndexModuleProduct.updateWithNonNullProperties(productModuleId, bean);
		//
		return null;
	}
	
	@SuppressWarnings("serial")
	public static class SaveModel extends TB_IndexModuleProduct{
		private @Getter @Setter Integer orderValue;
		private @Getter @Setter String comment;
		public SaveModel(ID_IndexModuleProduct productModuleId) {
			super.setId(productModuleId);
		}
	}
	
	public static class InputModel {
	
		@Comment("排序值")
//		@com.sh_lianjing.reflect.method.annotation.MethodOrder(1001)
		@javax.validation.constraints.NotNull
		@javax.validation.constraints.Max(Integer.MAX_VALUE)
		@javax.validation.constraints.Min(Integer.MIN_VALUE)
		private @Getter @Setter Integer orderValue;
		
		@Comment("说明")
//		@com.sh_lianjing.reflect.method.annotation.MethodOrder(2001)
		@javax.validation.constraints.Size(min=0, max=255)
		private @Getter @Setter String comment;
	}
	

}
